package logic

import (
	"cart_srv/model/redis"
	"context"

	"cart_srv/cart"
	"cart_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UpdateCartLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUpdateCartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateCartLogic {
	return &UpdateCartLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *UpdateCartLogic) UpdateCart(in *cart.UpdateCartRequest) (*cart.UpdateCartResponse, error) {
	err := redis.UpdateCart(int(in.GoodsId))
	if err != nil {
		logx.Error("修改失败")
		return nil, err
	}

	return &cart.UpdateCartResponse{}, nil
}
